package gmatgame.groupAndgame.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class SplashScreen extends Activity {
	protected boolean _active = true;
	protected int _splashtime = 5000;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.plashscreen);
		
		// tao thread dieu khien image
		Thread splashThread = new Thread() {
			@Override
			public void run() {
				try {
					int waited = 0;
					while (_active & (waited < _splashtime)) {
						sleep(100);
						if (_active) {
							waited += 100;
						}
					}
				} catch (InterruptedException ie) {
				} finally {
					finish();
					// new intent run home activity
					Intent homeActivity = new Intent(SplashScreen.this,
							GmatgameActivity.class);
					SplashScreen.this.startActivity(homeActivity);
					SplashScreen.this.finish();
					stop();
				}

			}
		};
		splashThread.start();
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if(event.getAction() == MotionEvent.ACTION_DOWN )
		{
			_active = false;
		}
		return true;
	}

	
	
}
